#ifndef VECTOR4_HPP
#define VECTOR4_HPP

#include <math.h>

class Vector4 {
private:
	double x, y, z, w;
public:
	Vector4():x(0), y(0), z(0), w(0) {}
	Vector4(double x, double y, double z, double w):x(x), y(y), z(z), w(w) {}
	void set(double x, double y, double z, double w) {
		this->x=x;
		this->y=y;
		this->z=z;
		this->w=w;
	}
	double getx() const { return x; }
	double gety() const { return y; }
	double getz() const { return z; }
	double geth() const { return w; }
	double operator[] (int i) const { if (i==0) return x; if (i==1) return y; if (i==2) return z; if (i==3) return w; return -1;}
	Vector4 add(Vector4 const &vector4) const {
		return Vector4(this->x + vector4.x, this->y + vector4.y, this->z + vector4.z, this->w + vector4.w);
	}
	Vector4 operator+(Vector4 const &vector4) const { return add(vector4); }
	Vector4 sub(Vector4 const &vector4) const {
		return Vector4(this->x - vector4.x, this->y - vector4.y, this->z - vector4.z, this->w - vector4.w);
	}
	Vector4 operator-(Vector4 const &vector4) const { return sub(vector4); }
	Vector4 dehomogenize() const {
		if (w==0) return *this;
		return Vector4(x/w, y/w, z/w, 1);
	}
};
#endif